<?php

    require_once($application_folder."/controllers/navigator.php");
    class excursions extends Navigator {

        function excursions () {
            parent::Navigator();

            $this->title("Izleti");

            /*MODELS*/
            $this->load->model('transports_m','transportsm');
            $this->load->model('excursions/excursions_m','excursionsm');
            $this->load->model('eshop/products_m','productsm');           
            $this->load->model('users_m','usersm'); 
            
            $this->load->library('form_validation');
            $this->load->helper('form');
            $this->data['p'] = 'izlet';
            $this->data['language'] = $this->lang_ses->getLang();
            $this->trace('Site Page',$this->data['p']);
            
            $this->usersm->check_log(1);
            
            /*Class*/
            $this->load->library('translate');
                
            //set local language
            $this->translate->setLang($this->lang_ses->getLang());
        }

        function add() {
            
            $this->title("Dodaj Izlet");
            
            $this->carabiner->js('tiny_mce/tiny_mce.js');  
            $this->carabiner->js('excursions/add.js');
            
            $this->navigate('excursions/add_v');
        }

        function create() {
            $this->excursionsm->create();
        }
     
        function views(){
            
            $this->title("Pregled izleta");
            
            $this->carabiner->js('tablesorter/jquery.tablesorter.js');
            $this->carabiner->js('excursions/views.js');
            $this->carabiner->css('tablesorter/style.css');             
            
            $this->data['excursions'] = $this->excursionsm->readAll();
            $this->navigate('excursions/views_v');
        }

        function edit($id){
            
            $this->title("Uredi izlet");
            
            $this->carabiner->js('tiny_mce/tiny_mce.js');
            $this->carabiner->js('excursions/edit.js');
            
            $this->data['excursion'] = $this->excursionsm->read($id);
            
            //print_r($this->data['excursion']);
            $this->navigate('excursions/edit_v');
        }

        function update() {
            $this->excursionsm->update();
        }

        function delete(){
            $this->excursionsm->delete();
        }
        
        function set_status($exc_id,$status){
            $this->excursionsm->set_status($exc_id,$status);
            $this->views();
        }

    }
?>